home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NetNews Offline 2
/
NetNews Offline Volume 2.iso
/
news
/
comp
/
std
/
c
/
303
< prev
next >
Wrap
Internet Message Format
|
1996-08-06
|
4KB
Path: tko.dec.com!diamond
From: diamond@tko.dec.com (Norman Diamond)
Newsgroups: comp.lang.c,comp.os.ms-windows.nt.misc,comp.programming,comp.std.c,comp.unix.aix
Subject: Re: function pointers
Date: 5 Feb 1996 03:46:51 GMT
Organization: Digital Equipment Corporation Japan , Tokyo
Message-ID: <4f3ujb$9s8@usenet.pa.dec.com>
References: <4eogio$gt0@giga.bga.com> <4eohgr$gt0@giga.bga.com> <sXEExQ9ytBGL084yn@csn.net> <4es7vo$bih@usenet.pa.dec.com> <4f090o$2hn4@ausnews.austin.ibm.com>
Reply-To: diamond@jrdv04.enet.dec-j.co.jp (Norman Diamond)
NNTP-Posting-Host: jit533.tko.dec.com
In article <4f090o$2hn4@ausnews.austin.ibm.com>, hook@austin.ibm.com (Gary R. Hook) writes:
>In article <4es7vo$bih@usenet.pa.dec.com>, diamond@tko.dec.com (Norman Diamond) writes:
>> After seeing several followups which were either wrong or else technically
>> correct but non-responsive to the original poster's problem, and seeing
>> which newsgroups they were posted to, I wish to point out that only one
>> followup correctly answered the original poster's problem.
>> Thad Smith's posting with message-id <sXEExQ9ytBGL084yn@csn.net>
>> had the correct answer (and another partial answer with correct warning).
>> If you try relying on any of the others, you will get bitten someday, or
>> if not you then innocent bystanders will get bitten by your work.
>Begging your pardon, but pretty much every one who responded to the post
>had a "correct" answer; the original question was how to get the code
>to compile on AIX.
There are a million ways to get a slightly changed code to compile on AIX,
some of which will cause core dumps at execution time, some of which will
execute to completion while printing wrong answers, some of which will be
luckier, and some of which will be unluckier. I did not see which part of
the original posting asked to avoid a slightly changed code that would obey
the standard, with possibility of compiling and executing correctly on all
conforming implementations.
>The original code was incorrect, in that the casting
>that was being done did not really address the complaint from the
>compiler. The "solution" is to properly perform the casts to the
>associated types, i.e. function pointers taking and returning the
>required data types, as opposed to casting to struct pointers, which
>doesn't affect the function pointer in the least.
Indeed, the solution is to PROPERLY perform the casts to the associated
types. Thad Smith's posting did this.
Your posting did not do this. You cast the function pointer type instead.
Your posting didn't include code to cast the arguments and parameters.
I'll take your word for it that under AIX, if a caller passes a void*
argument to a function which expected a double*, and the void* argument
does not get converted to the double* type of the parameter, the invoked
function will still work. Today anyway. I think your employer was aware
that this kind of game was not reliable, when it developed the syntax for
declaring ENTRYs in PL/I. C was invented around 7 years after PL/I and
this game did not become any more reliable during that time or since.
>The fact that what the original coder was trying to accomplish is
>quite non-portable, and can wreak havoc for others, was an appropriate
>comment by Thad, but the addition of his warning didn't make his
>answer any more correct than any of the others, did it? Or perhaps
>we saw different responses to the posed question...
Thad Smith posted both a correct answer *and* an addition of a warning
to the same kind of game that you posted without warning. Either one
of these would have been enough to make his answer more correct.
It sure does look like we saw different responses. Look again.
>Good for XL C for refusing to compile this sort of code without complaint.
I agree. Maybe you can learn from your colleagues.
--
<< If this were the company's opinion, I would not be allowed to post it. >>
"I paid money for this car, I pay taxes for vehicle registration and a driver's
license, so I can drive in any lane I want, and no innocent victim gets to call
the cops just 'cause the lane's not goin' the same direction as me" - J Spammer